﻿using System;
using System.Collections.Generic;

namespace K9Nano.Dependency
{
    public interface IIocHelper
    {
        bool IsRegister<T>() => IsRegister(typeof(T));
        bool IsRegister(Type type);

        IEnumerable<Type> GetRegisteredTypes(Func<Type, bool> filter);

        IEnumerable<Type> GetRegisteredTypes<TBase>()
        {
            var baseType = typeof(TBase);
            return GetRegisteredTypes(type => type.IsClass && (type.IsSubclassOf(baseType) || baseType.IsAssignableFrom(type)));
        }
    }
}